function init_i18n() {
	document.querySelector("head > title").innerHTML = chrome.i18n
			.getMessage("preferences")
			+ " - " + chrome.i18n.getMessage("extName");
	document.querySelector("#nav li.preferences span").innerHTML = chrome.i18n
			.getMessage("preferences");
	document.querySelector("#nav li.about a").innerHTML = chrome.i18n
			.getMessage("about");
	document.querySelector("#main .box h2").innerHTML = chrome.i18n
			.getMessage("preferences");
	document.querySelector("fieldset label[for=toggle]").innerHTML = chrome.i18n
			.getMessage("toggleBtnText");
	document.querySelector("fieldset label[for=minWidth]").innerHTML = chrome.i18n
			.getMessage("minImageSide");
	document.querySelector("#authorization label.title").innerHTML = chrome.i18n
			.getMessage("authorization")
}
window.addEventListener("load", function() {
	init_i18n();
	var b = document.querySelector("input[name=toggle]");
	var l = document.querySelector("input[name=toggle] ~ label");
	var k = document.querySelector("input[name=minWidth]");
	var j = document.querySelector("input[name=minWidth] ~ label");
	b.checked = !(localStorage.toggle == "off");
	l.innerHTML = localStorage.toggle == "off" ? chrome.i18n.getMessage("hide")
			: chrome.i18n.getMessage("show");
	k.value = j.innerHTML = localStorage.minWidth || 200;
	k.addEventListener("change", function() {
		j.innerHTML = localStorage.minWidth = this.value
	});
	b.addEventListener("click", function() {
		chrome.extension.sendRequest({
			msg : "toggle",
			toggle : this.checked
		}, function(m) {
			l.innerHTML = m.isToggleOn ? chrome.i18n.getMessage("show")
					: chrome.i18n.getMessage("hide")
		})
	});
	setInterval(function() {
		b.checked = !(localStorage.toggle == "off");
		l.innerHTML = localStorage.toggle == "off" ? chrome.i18n
				.getMessage("hide") : chrome.i18n.getMessage("show")
	}, 500);
	var a = Account.getUsers(Huaban.siteId);
	var e = null;
	for (_user in a) {
		e = a[_user];
		break
	}
	if (e) {
		var h = document.getElementById("authorization");
		var i = document.createElement("a");
		i.href = Utils.getUserUrl(e);
		i.target = "_blank";
		i.classList.add("icon");
		var g = new Image();
		if (e.avatar) {
			g.src = Utils.getImgUrl(e.avatar, "sq75")
		} else {
			g.src = "/images/default_buddy_icon.jpg"
		}
		var f = document.createTextNode(e.name);
		var d = chrome.i18n.getMessage("remove_auth");
		var c = document.createElement("span");
		c.classList.add("removeAuth");
		c.title = c.innerHTML = d;
		c.addEventListener("click", function() {
			h.innerHTML = "";
			h.style.display = "none";
			Account.removeUser(Huaban.siteId, e.id);
			return false
		});
		i.appendChild(g);
		i.appendChild(f);
		i.appendChild(c);
		h.appendChild(i);
		h.appendChild(c);
		h.style.display = "block"
	}
});